package com.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.entity.User;
import com.mapper.UserMapper;
import com.service.IAdminService;
import com.util.DateUtil;
import com.util.MD5;
import com.vo.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminServiceImpl extends ServiceImpl< UserMapper, User > implements IAdminService {
    @Autowired
    private UserMapper userMapper;
    private Logger logger= LoggerFactory.getLogger( UserServiceImpl.class );

    @Override
    public Result login(String phone, String password) {
        password= MD5.md5(password);
        QueryWrapper<User> wrapper = new QueryWrapper();
        wrapper.like("phone", phone).like("password", password).eq("power",90);
        List list= userMapper.selectList(wrapper);
        Result result=new Result();
        if(list.size()!=1){
            result.setCode(0);
            result.setMsg("查询失败");
            return result;
        }
        result.setCode(1);
        result.setData(list);
        return result;
    }
}
